* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  &::after,
  &::before {
    box-sizing: inherit;
  }
}

body {
  width: 100%;
  height: 100vh;
}

.wrapper {
  width: 400px;
  height: 400px;
  margin: 0 auto;
  margin-top: 50px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 10px;
  transition: 0.5s;
  @for $i from 1 through 9 {
    .item:nth-child(#{$i}) {
      background-color: hsl(calc($i * 40), 100%, 70%);
    }
    &:has(.item:nth-child(#{$i}):hover) {
      $r: floor(calc(($i - 1) / 3 + 1));
      $c: ($i - 1) % 3 + 1;
      $arr: 1fr 1fr 1fr;
      $rows: set-nth($arr, $r, 2fr);
      $cols: set-nth($arr, $c, 2fr);
      grid-template-columns: $cols;
      grid-template-rows: $rows;
    }
  }
}
